//
//  SNAssociatorViewController.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/12/16.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNRetailInvestorViewController.h"
#import "SNDetailInfoCell.h"
@interface SNRetailInvestorViewController ()<UITableViewDataSource,UITableViewDelegate>
/** tableView */
@property (nonatomic,weak) UITableView * tableView;

@end

@implementation SNRetailInvestorViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"详细信息";
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    CGRect frame = CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height - 64);
    UITableView * tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
    self.tableView = tableView;
    [self setupInit:tableView];
    
    [self.view addSubview:tableView];
    
    [self addObserver];
    [self addRequest];
}
#pragma mark - <addRequest>
- (void)addRequest {
    // addRequest
    
    //    [[ZXHTTPManager sharedManager] getUserInfoWithUserId:self.USERID certNo:nil completed:^(NSDictionary *jsonDict, NSError *error) {
    //
    //        logError;
    //
    //        if([jsonDict[@"status"] integerValue] == 1){
    //            // 失败
    //            NSLog(@"%@",jsonDict[@"message"]);
    //            [SNProgressManager showToView:self.view message:jsonDict[@"message"] afterDelay:2];
    //            return ;
    //        };
    //        NSLog(@"%@",jsonDict);
    //        NSDictionary * dict = jsonDict[@"result"][0];
    //        ZXUserDetailInfo * userDetailInfo = [ZXUserDetailInfo mj_objectWithKeyValues:dict];
    //
    //        self.userDetailInfo = userDetailInfo;
    //
    //        [self.tableView reloadData];
    //
    //    }];
    
}
#pragma mark - <addObserver>
- (void)addObserver {
    // addObserver
}
- (void)dealloc {
    NSLog(@"%@ %s %@",[self class], __func__ , @"im dying");
}

- (void)setupInit:(UITableView *)tableView {
    tableView.delegate = self;
    tableView.dataSource = self;
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 10)];
    headerView.backgroundColor = HexRGB(0xf5f5f5);
    tableView.tableHeaderView = headerView;
    tableView.backgroundColor = HexRGB(0xf5f5f5);
    //    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.separatorInset = UIEdgeInsetsZero;
    tableView.tableFooterView = [UIView new];
    [self setHeights:tableView];
    [self registerNib:tableView];
    [self registerClass:tableView];
}
#pragma mark - <Register>
/** registerNib */
- (void)registerNib:(UITableView *)tableView {
    [tableView registerNib:[UINib nibWithNibName:NSStringFromClass([SNDetailInfoCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([SNDetailInfoCell class])];
}
/** registerClass */
- (void)registerClass:(UITableView *)tableView {

    [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];

}
#pragma mark - <SetHeights>
/** setHeights */
- (void)setHeights:(UITableView *)tableView {
    
    tableView.estimatedRowHeight = 54;
    tableView.rowHeight = UITableViewAutomaticDimension;
    
}

#pragma mark - <UITableViewDataSource>
/** 组数 */
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}
/** 行数 */
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return 6;
}
//MARK: -
//MARK: - cell
/** cell */
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    SNDetailInfoCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SNDetailInfoCell class])];
    
    switch (indexPath.row) {
        case 0:
            [cell configCellWithKeyString:@"姓名" valueString:kFileterString(self.model.legalName)];
            break;
//        case 1:
//            [cell configCellWithKeyString:@"社员编号" valueString:@"未知"];
//            break;
        case 1:
            [cell configCellWithKeyString:@"身份证号码" valueString:@"未知"];
            break;
        case 2:
            [cell configCellWithKeyString:@"手机号码" valueString:kFileterString(self.model.legalPhone)];
            break;
        case 3:
            [cell configCellWithKeyString:@"所在地区" valueString:kFileterString(self.model.filteredAddress)];
            break;
        case 4:
            [cell configCellWithKeyString:@"身份" valueString:@"散户"];
            break;
            
        default:
            break;
    }
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    return cell;
}
#pragma mark - <UITableViewDelegate>

/** 选中一行 */
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"%s", __func__);
    //    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
/** 取消 选中 */
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(3_0) {
    NSLog(@"%s", __func__);
}

@end
